package org.matchergen.apt;

import java.io.IOException;
import java.io.OutputStream;

import javax.annotation.processing.Filer;

import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JPackage;

public class AptCodeWriter extends CodeWriter {
	Filer filer;

	public AptCodeWriter(Filer filer) {
		super();

		this.filer = filer;
	}

	@Override
	public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
		fileName = fileName.substring(0, fileName.length() - 5);

		return filer.createSourceFile(pkg.name() + "." + fileName).openOutputStream();
	}

	@Override
	public void close() throws IOException {
		// nichts
	}
}
